import os
from common import Path_API
import logging


def loggin():  # 日志封装
    # 设置日志收集器
    log = logging.getLogger("tang")
    # 设置系统收集日志的等级
    log.setLevel("DEBUG")

    # 终端收集器
    sh = logging.StreamHandler()
    sh.setLevel("INFO")
    log.addHandler(sh)

    # 文件收集器
    fh = logging.FileHandler(os.path.join(Path_API.REPORT_DIR, "tang.log"), encoding='utf-8')
    fh.setLevel("INFO")
    log.addHandler(fh)

    # 设置格式
    log_fomater = logging.Formatter("%(asctime)s - [%(filename)s-->line:%(lineno)d] - %(levelname)s: %(message)s")
    sh.setFormatter(log_fomater)
    fh.setFormatter(log_fomater)
    return log


log1 = loggin()
